<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="申请人">
              <select-user-by-dep :multi="false" v-model="queryParam.documentNo"/>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="车辆类型">
              <j-dict-select-tag type="list" dictCode="car_type_oa" v-model="queryParam.applyUser" placeholder="请选择车辆类型" />
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="日期">
              <j-date placeholder="请选择日期" v-model="queryParam.createTime" style="width: 100%" />
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- table区域-begin -->
    <div style="display: flex; justify-content: end;">
      <p style="width: 70px; height: 30px;background: orange; font-size:10px; margin-right: 30px; color: #ffffff; text-align:center;line-height: 30px;border-radius:2px;">已占用</p>
      <p style="width: 70px; height: 30px;background: gray;font-size: 10px;color:#ffffff; text-align:center;line-height: 30px;border-radius:2px;">暂不可用</p>
    </div>
    <div>
      <a-table
        :columns="columnData"
        :data-source="dataSource"
        :scroll="{x:'150%'}"
        ref="table"
        bordered
        rowKey="key"
        :loading="loading"
        size="middle">
        <p slot="carName" slot-scope="text, record" style="text-align: center;margin: 0px;">
          <a style="font-size: 14px;" @click="getDetail(record)">{{ record.carName }}</a>
          <a style="font-size:16px;" @click="getDetail(record)">{{ record.carNum }}</a>
        </p>
      </a-table>
    </div>
    <EoaCaringModal ref="mettingModal" @ok="handleOk"></EoaCaringModal>
    <ErpCarInfoModal ref="modalForm"></ErpCarInfoModal>
  </a-card>
</template>

<script>
import EoaCaringModal from '@/views/oa/erpcarusing/modules/ErpCarUsingModal'
import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgBpmListMixin } from '@/mixins/JeecgBpmListMixin'
import { DisabledAuthFilterMixin } from '@/mixins/DisabledAuthFilterMixin'
import { postAction } from '@/api/manage'
import moment from 'moment'
import { mapGetters } from 'vuex';
import ErpCarInfoModal from './modules/ErpCarInfoModal'
import SelectUserByDep from '@/views/scy/components/SelectUserByDep'
var isColSpan = 0
export default {
    name: 'ErpCarMaintenanceList',
    mixins: [JeecgBpmListMixin, mixinDevice, DisabledAuthFilterMixin],
    components: {
      ErpCarInfoModal,
      SelectUserByDep,
      EoaCaringModal
    },
    data () {
      return {
        loading: true,
        resources: [],
        columns: [], // 防止JeecgBpmListMixin报错
        columnData: [], // 列表
        dataSource: [], // 列表数据
        calendarParam: {},
        queryParam: {
          documentNo: null,
          applyUser: null,
          createTime: null
        },
        url: {
          list: '/api/erp/carmaintenance/erpCarMaintenance/list',
          delete: '/api/erp/carmaintenance/erpCarMaintenance/delete',
          deleteBatch: '/api/erp/carmaintenance/erpCarMaintenance/deleteBatch',
          exportXlsUrl: '/api/erp/carmaintenance/erpCarMaintenance/exportXls',
          importExcelUrl: '/api/erp/carmaintenance/erpCarMaintenance/importExcel',
          bizCount: '/api/erp/carmaintenance/erpCarMaintenance/bizCount'
        },
        // 代码生成后需手动设置流程编码
        flowCode: 'dev_erp_car_maintenance_001',
        formUrl: 'scy/carmaintenance/modules/ErpCarMaintenanceForm',
        formUrlMobile: '',
        dictOptions: {},
        superFieldList: [],
        currentDate: null // 当前日期
      }
    },
    created() {
      // this.getSuperFieldList();
      this.currentDate = moment().format('YYYY-MM-DD') // 当前时间
      this.columnList() // 获取列表的头
      this.loadRoom()
    },
    computed: {
      importExcelUrl: function() {
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      }
    },
    methods: {
      ...mapGetters(['userInfo']),
      // 日历表格
      resourceChange (e) {
        // this.getSuperFieldList()
      },
      // 查看详情
      getDetail(record) {
        this.$refs.modalForm.edit(record);
        this.$refs.modalForm.title = '详情';
        this.$refs.modalForm.disableSubmit = true;
      },
      columnList () {
        this.columnData = [
          { title: '车辆类型', dataIndex: 'carName', key: 'carName', align: 'center', scopedSlots: { customRender: 'carName' } },
          { title: '管理员', dataIndex: 'carAdmin_dictText', key: 'carAdmin_dictText', align: 'center' },
          {
            title: this.currentDate,
            dataIndex: this.currentDate,
            key: this.currentDate,
            align: 'center',
            customCell: this.renderTdBackground1,
            ellipsis: true,
            customRender: (value, row, index) => {
              const obj = {
                children: value,
                attrs: {}
              }
              if (value) {
                obj.children = row.useParking[value - 1].handlerId_dictText + ',' + row.useParking[value - 1].applyDept_dictText
              }
              obj.attrs.colSpan = this.colspanMerge(value, row, index, this.currentDate)
              return obj;
            }
          },
          {
            title: moment(this.currentDate).add(1, 'days').format('YYYY-MM-DD'),
            dataIndex: moment(this.currentDate).add(1, 'days').format('YYYY-MM-DD'),
            key: moment(this.currentDate).add(1, 'days').format('YYYY-MM-DD'),
            align: 'center',
            customCell: this.renderTdBackground2,
            ellipsis: true,
            customRender: (value, row, index) => {
              const obj = {
                children: value,
                attrs: {}
              }
              if (value) {
                obj.children = row.useParking[value - 1].handlerId_dictText + ',' + row.useParking[value - 1].applyDept_dictText
              }
              obj.attrs.colSpan = this.colspanMerge(value, row, index, moment(this.currentDate).add(1, 'days').format('YYYY-MM-DD'))
              return obj;
            }
          },
          {
            title: moment(this.currentDate).add(2, 'days').format('YYYY-MM-DD'),
            dataIndex: moment(this.currentDate).add(2, 'days').format('YYYY-MM-DD'),
            key: moment(this.currentDate).add(2, 'days').format('YYYY-MM-DD'),
            align: 'center',
            customCell: this.renderTdBackground3,
            ellipsis: true,
            customRender: (value, row, index) => {
              const obj = {
                children: value,
                attrs: {}
              }
              if (value) {
                obj.children = row.useParking[value - 1].handlerId_dictText + ',' + row.useParking[value - 1].applyDept_dictText
              }
              obj.attrs.colSpan = this.colspanMerge(value, row, index, moment(this.currentDate).add(2, 'days').format('YYYY-MM-DD'))
              return obj;
            }
          },
          {
            title: moment(this.currentDate).add(3, 'days').format('YYYY-MM-DD'),
            dataIndex: moment(this.currentDate).add(3, 'days').format('YYYY-MM-DD'),
            key: moment(this.currentDate).add(3, 'days').format('YYYY-MM-DD'),
            align: 'center',
            customCell: this.renderTdBackground4,
            ellipsis: true,
            customRender: (value, row, index) => {
              const obj = {
                children: value,
                attrs: {}
              }
              if (value) {
                obj.children = row.useParking[value - 1].handlerId_dictText + ',' + row.useParking[value - 1].applyDept_dictText
              }
              obj.attrs.colSpan = this.colspanMerge(value, row, index, moment(this.currentDate).add(3, 'days').format('YYYY-MM-DD'))
              return obj;
            }
          },
          {
            title: moment(this.currentDate).add(4, 'days').format('YYYY-MM-DD'),
            dataIndex: moment(this.currentDate).add(4, 'days').format('YYYY-MM-DD'),
            key: moment(this.currentDate).add(4, 'days').format('YYYY-MM-DD'),
            align: 'center',
            customCell: this.renderTdBackground5,
            ellipsis: true,
            customRender: (value, row, index) => {
              const obj = {
                children: value,
                attrs: {}
              }
              if (value) {
                obj.children = row.useParking[value - 1].handlerId_dictText + ',' + row.useParking[value - 1].applyDept_dictText
              }
              obj.attrs.colSpan = this.colspanMerge(value, row, index, moment(this.currentDate).add(4, 'days').format('YYYY-MM-DD'))
              return obj;
            }
          },
          {
            title: moment(this.currentDate).add(5, 'days').format('YYYY-MM-DD'),
            dataIndex: moment(this.currentDate).add(5, 'days').format('YYYY-MM-DD'),
            key: moment(this.currentDate).add(5, 'days').format('YYYY-MM-DD'),
            align: 'center',
            customCell: this.renderTdBackground6,
            ellipsis: true,
            customRender: (value, row, index) => {
              const obj = {
                children: value,
                attrs: {}
              }
              if (value) {
                obj.children = row.useParking[value - 1].handlerId_dictText + ',' + row.useParking[value - 1].applyDept_dictText
              }
              obj.attrs.colSpan = this.colspanMerge(value, row, index, moment(this.currentDate).add(5, 'days').format('YYYY-MM-DD'))
              return obj;
            }
          },
          {
            title: moment(this.currentDate).add(6, 'days').format('YYYY-MM-DD'),
            dataIndex: moment(this.currentDate).add(6, 'days').format('YYYY-MM-DD'),
            key: moment(this.currentDate).add(6, 'days').format('YYYY-MM-DD'),
            align: 'center',
            customCell: this.renderTdBackground7,
            ellipsis: true,
            customRender: (value, row, index) => {
              const obj = {
                children: value,
                attrs: {}
              }
              if (value) {
                obj.children = row.useParking[value - 1].handlerId_dictText + ',' + row.useParking[value - 1].applyDept_dictText
              }
              obj.attrs.colSpan = this.colspanMerge(value, row, index, moment(this.currentDate).add(6, 'days').format('YYYY-MM-DD'))
              return obj;
            }
          },
          {
            title: moment(this.currentDate).add(7, 'days').format('YYYY-MM-DD'),
            dataIndex: moment(this.currentDate).add(7, 'days').format('YYYY-MM-DD'),
            key: moment(this.currentDate).add(7, 'days').format('YYYY-MM-DD'),
            align: 'center',
            customCell: this.renderTdBackground8,
            ellipsis: true,
            customRender: (value, row, index) => {
              const obj = {
                children: value,
                attrs: {}
              }
              if (value) {
                obj.children = row.useParking[value - 1].handlerId_dictText + ',' + row.useParking[value - 1].applyDept_dictText
              }
              obj.attrs.colSpan = this.colspanMerge(value, row, index, moment(this.currentDate).add(7, 'days').format('YYYY-MM-DD'))
              return obj;
            }
          },
          {
            title: moment(this.currentDate).add(8, 'days').format('YYYY-MM-DD'),
            dataIndex: moment(this.currentDate).add(8, 'days').format('YYYY-MM-DD'),
            key: moment(this.currentDate).add(8, 'days').format('YYYY-MM-DD'),
            align: 'center',
            customCell: this.renderTdBackground9,
            ellipsis: true,
            customRender: (value, row, index) => {
              const obj = {
                children: value,
                attrs: {}
              }
              if (value) {
                obj.children = row.useParking[value - 1].handlerId_dictText + ',' + row.useParking[value - 1].applyDept_dictText
              }
              obj.attrs.colSpan = this.colspanMerge(value, row, index, moment(this.currentDate).add(8, 'days').format('YYYY-MM-DD'))
              return obj;
            }
          },
          {
            title: moment(this.currentDate).add(9, 'days').format('YYYY-MM-DD'),
            dataIndex: moment(this.currentDate).add(9, 'days').format('YYYY-MM-DD'),
            key: moment(this.currentDate).add(9, 'days').format('YYYY-MM-DD'),
            align: 'center',
            customCell: this.renderTdBackground10,
            ellipsis: true,
            customRender: (value, row, index) => {
              const obj = {
                children: value,
                attrs: {}
              }
              if (value) {
                obj.children = row.useParking[value - 1].handlerId_dictText + ',' + row.useParking[value - 1].applyDept_dictText
              }
              obj.attrs.colSpan = this.colspanMerge(value, row, index, moment(this.currentDate).add(9, 'days').format('YYYY-MM-DD'))
              return obj;
            }
          },
          {
            title: moment(this.currentDate).add(10, 'days').format('YYYY-MM-DD'),
            dataIndex: moment(this.currentDate).add(10, 'days').format('YYYY-MM-DD'),
            key: moment(this.currentDate).add(10, 'days').format('YYYY-MM-DD'),
            align: 'center',
            customCell: this.renderTdBackground11,
            ellipsis: true,
            customRender: (value, row, index) => {
              const obj = {
                children: value,
                attrs: {}
              }
              if (value) {
                obj.children = row.useParking[value - 1].handlerId_dictText + ',' + row.useParking[value - 1].applyDept_dictText
              }
              obj.attrs.colSpan = this.colspanMerge(value, row, index, moment(this.currentDate).add(10, 'days').format('YYYY-MM-DD'))
              return obj;
            }
          },
          {
            title: moment(this.currentDate).add(11, 'days').format('YYYY-MM-DD'),
            dataIndex: moment(this.currentDate).add(11, 'days').format('YYYY-MM-DD'),
            key: moment(this.currentDate).add(11, 'days').format('YYYY-MM-DD'),
            align: 'center',
            customCell: this.renderTdBackground12,
            ellipsis: true,
            customRender: (value, row, index) => {
              const obj = {
                children: value,
                attrs: {}
              }
              if (value) {
                obj.children = row.useParking[value - 1].handlerId_dictText + ',' + row.useParking[value - 1].applyDept_dictText
              }
              obj.attrs.colSpan = this.colspanMerge(value, row, index, moment(this.currentDate).add(11, 'days').format('YYYY-MM-DD'))
              return obj;
            }
          },
          {
            title: moment(this.currentDate).add(12, 'days').format('YYYY-MM-DD'),
            dataIndex: moment(this.currentDate).add(12, 'days').format('YYYY-MM-DD'),
            key: moment(this.currentDate).add(12, 'days').format('YYYY-MM-DD'),
            align: 'center',
            customCell: this.renderTdBackground13,
            ellipsis: true,
            customRender: (value, row, index) => {
              const obj = {
                children: value,
                attrs: {}
              }
              if (value) {
                obj.children = row.useParking[value - 1].handlerId_dictText + ',' + row.useParking[value - 1].applyDept_dictText
              }
              obj.attrs.colSpan = this.colspanMerge(value, row, index, moment(this.currentDate).add(12, 'days').format('YYYY-MM-DD'))
              return obj;
            }
          },
          {
            title: moment(this.currentDate).add(13, 'days').format('YYYY-MM-DD'),
            dataIndex: moment(this.currentDate).add(13, 'days').format('YYYY-MM-DD'),
            key: moment(this.currentDate).add(13, 'days').format('YYYY-MM-DD'),
            align: 'center',
            customCell: this.renderTdBackground14,
            ellipsis: true,
            customRender: (value, row, index) => {
              const obj = {
                children: value,
                attrs: {}
              }
              if (value) {
                obj.children = row.useParking[value - 1].handlerId_dictText + ',' + row.useParking[value - 1].applyDept_dictText
              }
              obj.attrs.colSpan = this.colspanMerge(value, row, index, moment(this.currentDate).add(13, 'days').format('YYYY-MM-DD'))
              return obj;
            }
          },
          {
            title: moment(this.currentDate).add(14, 'days').format('YYYY-MM-DD'),
            dataIndex: moment(this.currentDate).add(14, 'days').format('YYYY-MM-DD'),
            key: moment(this.currentDate).add(14, 'days').format('YYYY-MM-DD'),
            align: 'center',
            customCell: this.renderTdBackground15,
            ellipsis: true,
            customRender: (value, row, index) => {
              const obj = {
                children: value,
                attrs: {}
              }
              if (value) {
                obj.children = row.useParking[value - 1].handlerId_dictText + ',' + row.useParking[value - 1].applyDept_dictText
              }
              obj.attrs.colSpan = this.colspanMerge(value, row, index, moment(this.currentDate).add(14, 'days').format('YYYY-MM-DD'))
              return obj;
            }
          }
        ]
      },

      // 获取数据
      loadRoom() {
        isColSpan = 0
        this.loading = true
        postAction('/api/erp/erpcarusing/erpCarUsing/getUsingCarInfo', {
          carType: this.calendarParam.applyUser || '',
          handlerId: this.calendarParam.documentNo || '',
          time: this.calendarParam.createTime || ''
        }).then(res => {
          if (res.success) {
            let resources = []
            if (res.result != null) {
              res.result.records[0].erpCarInfoList.map((value, index1) => {
                // 循环有多少个车辆类型
                let obj = {};
                obj = { ...value }
                obj.id = value.id; // id值
                obj.key = index1 + '' // 作为唯一标识key
                obj.useParking = [] // 数组 装所有申请车辆的数据

                res.result.records[0].erpCarUsingList.map((item, index2) => {
                  // 循环申请的车辆次数
                  obj.key = obj.key + index2 // 作为唯一标识key
                  obj.useParking.push(item) // 数组 装所有申请车辆的数据

                  // 当没有提交流程，只保存，直接不走下面代码
                  // if (item && item.bpmStatus == 1) {
                  //   return false
                  // }

                  // 匹配车辆使用
                  if ( item && item.bpmStatus != 1 && item.bpmStatus != 4 && item.carId == value.id) {
                    // 当有车辆开始使用日期和结束日期
                    if (item.reserveStartTime && item.reserveEndTime) {
                      // 获取开始使用日期和结束使用日期天数差

                      /* 判断列表中的当前日期是否大于开始日期 */
                      var startDate = ''
                      /* 开始日期 */
                      var reserveStartDate = moment(item.reserveStartTime).format('YYYY-MM-DD'); // 开始日期
                      /* 开始日期和当前列表开始日期作比较 */
                      var dateStartDiff = moment(reserveStartDate).diff(moment(this.currentDate), 'days')
                      if (dateStartDiff > 0) {
                        // 当开始日期大于列表开始日期
                        startDate = reserveStartDate
                      } else {
                        // 当开始日期小于列表开始日期
                        startDate = this.currentDate
                      }
                      var endDate = ''
                      if (item.returnCarTime) {
                        // 当有提前归还车辆的日期
                        var returnCarDate = moment(item.returnCarTime).format('YYYY-MM-DD')
                        var dateDiff = moment(returnCarDate).diff(moment(startDate), 'days') // 归还日期和开始日期作比较
                        var reserveEndDate = moment(item.reserveEndTime).format('YYYY-MM-DD'); // 结束日期
                        var dateEndDiff = moment(returnCarDate).diff(moment(reserveEndDate), 'days')
                        // 判断归还日期是否大于结束日期
                        if (dateEndDiff >= 0) {
                          // 归还日期大于结束日期
                          endDate = moment(item.reserveEndTime).format('YYYY-MM-DD'); // 直接就是结束日期（超出的日期线下自己解决）
                        } else {
                          // 归还日期小于结束日期 则判断归还日期是否大于开始日期
                          if (dateDiff >= 0) {
                            // 当归还日期大于等于开始日期 则结束日期就是归还日期
                            endDate = moment(item.returnCarTime).format('YYYY-MM-DD'); // 结束日期
                          } else {
                            // 当归还日期小于开始日期 则不计算日期，日期全部放开
                            startDate = ''
                            endDate = ''
                          }
                        }
                      } else {
                        endDate = moment(item.reserveEndTime).format('YYYY-MM-DD'); // 结束日期
                      }
                      // var endDate = moment(item.reserveEndTime).format('YYYY-MM-DD'); // 结束日期
                      var timeDate = 'timeDate' + (index2 + 1)
                      var dateNum = moment(endDate).diff(startDate, 'day') + 1 // 当是同一天的时候则默认加一
                      obj[timeDate] = dateNum
                      // 使用日期和结束日期中间的日期循环出来
                      for (var i = 0; i < dateNum; i++) {
                        obj.key = obj.key + i
                        var date = moment(startDate).add(i, 'days').format('YYYY-MM-DD'); // 获取每次的使用日期和结束日期中间日期
                        obj[date] = index2 + 1
                    }
                    }
                  }
                })

                resources.push(obj)
              })
            }
            this.dataSource = resources;
          }
        }).finally(() => {
          this.loading = false
        })
      },

      // 修改预约成功的颜色
      renderTdBackground1(record, index, value) {
        return this.renderTdBackground(this.currentDate, record, index)
      },
      renderTdBackground2(record, index) {
          return this.renderTdBackground(moment(this.currentDate).add(1, 'days').format('YYYY-MM-DD'), record, index)
      },
      renderTdBackground3(record, index) {
          return this.renderTdBackground(moment(this.currentDate).add(2, 'days').format('YYYY-MM-DD'), record, index)
      },
      renderTdBackground4(record, index) {
          return this.renderTdBackground(moment(this.currentDate).add(3, 'days').format('YYYY-MM-DD'), record, index)
      },
      renderTdBackground5(record, index) {
          return this.renderTdBackground(moment(this.currentDate).add(4, 'days').format('YYYY-MM-DD'), record, index)
      },
      renderTdBackground6(record, index) {
          return this.renderTdBackground(moment(this.currentDate).add(5, 'days').format('YYYY-MM-DD'), record, index)
      },
      renderTdBackground7(record, index) {
          return this.renderTdBackground(moment(this.currentDate).add(6, 'days').format('YYYY-MM-DD'), record, index)
      },
      renderTdBackground8(record, index) {
          return this.renderTdBackground(moment(this.currentDate).add(7, 'days').format('YYYY-MM-DD'), record, index)
      },
      renderTdBackground9(record, index) {
          return this.renderTdBackground(moment(this.currentDate).add(8, 'days').format('YYYY-MM-DD'), record, index)
      },
      renderTdBackground10(record, index) {
          return this.renderTdBackground(moment(this.currentDate).add(9, 'days').format('YYYY-MM-DD'), record, index)
      },
      renderTdBackground11(record, index) {
          return this.renderTdBackground(moment(this.currentDate).add(10, 'days').format('YYYY-MM-DD'), record, index)
      },
      renderTdBackground12(record, index) {
          return this.renderTdBackground(moment(this.currentDate).add(11, 'days').format('YYYY-MM-DD'), record, index)
      },
      renderTdBackground13(record, index) {
          return this.renderTdBackground(moment(this.currentDate).add(12, 'days').format('YYYY-MM-DD'), record, index)
      },
      renderTdBackground14(record, index) {
          return this.renderTdBackground(moment(this.currentDate).add(13, 'days').format('YYYY-MM-DD'), record, index)
      },
      renderTdBackground15(record, index) {
          return this.renderTdBackground(moment(this.currentDate).add(14, 'days').format('YYYY-MM-DD'), record, index)
      },

      // 渲染有数据的单元格的颜色
      renderTdBackground (time, record, index) {
        let row = record.useParking[record[time] - 1]
        if (record.carState != 1) {
          return {
            // 这个style就是我自定义的属性，也就是官方文档中的props
            style: {
                // 行背景色
                'background-color': 'gray'
            },
            // 编辑事件
            on: {
                // 鼠标单击行
                click: event => {
                    this.$message.warning('暂不可用')
                }
            }
          }
        }
        if (!!row && row.bpmStatus != 1 && row.bpmStatus != 4) {
          return {
            // 这个style就是我自定义的属性，也就是官方文档中的props
            style: {
                // 行背景色
                'background-color': 'orange'
            },
            // 编辑事件
            on: {
                // 鼠标单击行
                click: event => {
                  var dataIndex = record[time] - 1
                  var editData = record.useParking[dataIndex]
                  if (record.useParking[dataIndex].handlerId != this.userInfo().empId) {
                    this.$message.warning('暂无编辑权限！')
                    return false
                  }
                  this.$refs.mettingModal.edit(editData)
                  if (!!editData && editData.bpmStatus !== '1' && editData.bpmStatus !== '4') {
                    this.$refs.mettingModal.disableSubmit = true
                  } else {
                    this.$refs.mettingModal.disableSubmit = false
                  }
                }
            }
          }
        }
        return {
            style: {
              // 行背景色
              'cursor': 'pointer'
            },
            // 添加事件
            on: {
                // 鼠标单击行
                click: event => {
                  // var date = moment(time).add(1, 'days').format('YYYY-MM-DD'); // 获取每次的使用日期和结束日期中间日期
                  record.startStr = time
                  record.endStr = time
                  this.$refs.mettingModal.disableSubmit = false
                  this.$refs.mettingModal.add(record)
                  this.$refs.mettingModal.isOk = true
                }
            }
        }
      },

      // 获取单元格合并
      colspanMerge(value, row, index, time) {
        if (value) {
          var colNum = 0
          if (isColSpan == value) {
            colNum = 0
          } else if (isColSpan != value) {
            isColSpan = value
            var num = row[time]
            var timeNum = 'timeDate' + num
            colNum = row[timeNum]
          }
          return colNum
        } else {
          isColSpan = 0
        }
      },

      searchQuery () {
        this.calendarParam = this.queryParam
        if (this.queryParam.createTime) {
          this.currentDate = moment(this.queryParam.createTime).format('YYYY-MM-DD') // 当前时间
        }
        this.columnList()
        this.loadRoom()
      },
      searchReset () {
        this.calendarParam = this.queryParam = {}
        this.currentDate = moment().format('YYYY-MM-DD') // 当前时间
        this.columnList()
        this.loadRoom()
      },

      handleOk () {
        this.loadRoom()
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>
